/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package researchgrants.utils;

/**
 *
 * @author DOStudent1
 */
public class StringUtils {
    public static String encodeHTML(String s)
    {
        StringBuffer out = new StringBuffer();
        for(int i=0; i<s.length(); i++)
        {
            char c = s.charAt(i);
            if(c > 127 || c=='"' || c=='<' || c=='>' || c==13 || c==10)
            {
               if ((c==13) || (c==10)) {
                   out.append("<br>");
               } else {
                out.append("&#"+(int)c+";");
               }
            }
            else
            {
                out.append(c);
            }
        }
        return out.toString();
    }

}
